

import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() => runApp( MyApp());

///滑动删除模块
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHome(),
    );
  }
}
class MyHome extends StatelessWidget {
  final List<String> items = new List<String>.generate(30, (index) => "items ${index+1}");
   MyHome({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('swipe to dismiss'),),
      body: ListView.builder(
          itemCount: items.length,
          itemBuilder: ( context,  index){
            return Dismissible(key: new Key(items[index]),
                onDismissed: (direction)  {
                    items.removeAt(index);
                    Scaffold.of(context).showBottomSheet((context) => Text('删除记录'),);
                },
                child: ListTile(
                  title: Text('${items[index]}'),
                ));
          },
      ),
    );
  }
}
